<?php
$child_pid = [];
pcntl_signal(SIGCHLD,function (){
   global  $child_pid;
   $child_pid_num = count($child_pid);
   if ($child_pid_num>0){
       foreach ($child_pid as $pid_key=>$pid_item){
          $wait_result = pcntl_waitpid($pid_item,$status,WNOHANG);
          if ($wait_result==$pid_item || $wait_result==-1){
              unset($child_pid[$pid_key]);
          }
       }
   }
});

for ($i=1;$i<=5;$i++){
   $_pid = pcntl_fork();
   if ($_pid<0){
       exit();
   }else if ($_pid==0){
       cli_set_process_title("php worker process");
       exit();
   }else if ($_pid>0){
       $child_pid[] = $_pid;
   }
}